﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SeaBattle.Domain.Abstract;
using SeaBattle.Domain.Entities;

namespace SeaBattle.Domain.Concrete
{
    public class FakeFleetRepository : IFleetRepository
    {
        private static List<Fleet> fleetCollection = new List<Fleet>();

        /// <summary>
        /// Creates the fleet.
        /// </summary>
        /// <param name="maxShipCount">The max ship count.</param>
        /// <param name="maxPartCount">The max part count.</param>
        /// <returns></returns>
        public Fleet CreateFleet(byte maxShipCount, byte maxPartCount)
        {
            var fleet = new Fleet(maxShipCount, maxPartCount) { Id = fleetCollection.Count + 1 };
            fleetCollection.Add(fleet);
            return fleet;
        }

        /// <summary>
        /// Gets the fleet.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <returns></returns>
        public Fleet GetFleet(int id)
        {
            return fleetCollection.FirstOrDefault(x => x.Id == id);
        }

        /// <summary>
        /// Saves the fleet.
        /// </summary>
        /// <param name="fleet">The fleet.</param>
        /// <returns></returns>
        public Fleet SaveFleet(Fleet fleet)
        {
            return fleet;
        }
    }
}
